package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPageParamDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/nursing/plan")
@RestController
@Api(tags = "护理计划有关接口操作")
public class NursingPlanController {

    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult<List<NursingPlanVo>> getAll(){

        List<NursingPlanVo> list =nursingPlanService.getAll();
        return ResponseResult.success(list);

    }

    @PostMapping
    @ApiOperation("护理计划添加操作")
    public ResponseResult add(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.add(nursingPlanDto);
        return ResponseResult.success();
    }


    @GetMapping("/search")
    @ApiOperation("护理计划分页查询")
    public ResponseResult<PageResponse<NursingPlanVo>> get(NursingPageParamDto nursingPageParamDto){

        PageResponse<NursingPlanVo> list=nursingPlanService.get(nursingPageParamDto);
        return ResponseResult.success(list);
    }

    @GetMapping("/{id}")
    @ApiOperation("护理计划根据id查询")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Integer id ){

        NursingPlanVo nursingPlanVo=nursingPlanService.getById(id);
        return ResponseResult.success(nursingPlanVo);
    }

    @PutMapping
    @ApiOperation("护理计划根据ID修改")
    public ResponseResult updateById(@RequestBody NursingPlanDto nursingPlanDto){

        nursingPlanService.updateById(nursingPlanDto);
        return ResponseResult.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("护理计划删除操作")
    public ResponseResult delete(@PathVariable Integer id){
        nursingPlanService.delete(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("护理计划启用禁用操作")
    public ResponseResult putStatus(@PathVariable Integer id,
                                    @PathVariable Integer status){
        nursingPlanService.putStatus(id,status);
        return ResponseResult.success();
    }


}
